var express = require('express');
var router = express.Router();
var User = require('./user');
var URL = require('url')

/* GET users listing. */
router.get('/', function(req, res, next) {
  res.send('respond with a resource');
});

router.get('/getUserInfo',function(req,res,next){
 
  var user = new User();
  var params = URL.parse(req.url,true).query;
  if(params.id == '1'){
    user.name = "ligh";
    user.age = "1";
    user.age = "北京市";
  }else{
    user.name = "SPTING";
    user.age = "2";
    user.city = "杭州市"
  }
  var response = {status:1,data:user};
  res.send(JSON.stringify(response));
});


router.get('/api/product/all',function(req,res,next){
  var response = {
    status:1,
    products:[
      {
        p_icon:'test1.jpg',
        p_title:'吃的吃的',
        p_summary:'123',
        p_priceA:'5000',
        p_duration:'30'
      },{
        p_icon:'test1.jpg',
        p_title:'吃的吃的',
        p_summary:'123',
        p_priceA:'5000',
        p_duration:'30'
      },{
        p_icon:'test1.jpg',
        p_title:'吃的吃的',
        p_summary:'123',
        p_priceA:'5000',
        p_duration:'30'
      }
    ]
  };
  res.send(response);
})

router.get('/api/product/recent',function(req,res,next){
  var response = {
    status:1,
    products:[
      {
        p_icon:'test2.jpg',
        p_title:'吃的吃的',
        p_summary:'123',
        p_priceA:'5000',
        p_duration:'30'
      },{
        p_icon:'test2.jpg',
        p_title:'吃的吃的',
        p_summary:'123',
        p_priceA:'5000',
        p_duration:'30'
      },{
        p_icon:'test2.jpg',
        p_title:'吃的吃的',
        p_summary:'123',
        p_priceA:'5000',
        p_duration:'30'
      }
    ]
  };
  res.send(response);
})

router.get('/api/product/hot',function(req,res,next){
  var response = {
    status:1,
    products:[
      {
        p_icon:'test1.jpg',
        p_title:'吃的吃的',
        p_summary:'123',
        p_priceA:'5000',
        p_duration:'30'
      },{
        p_icon:'test2.jpg',
        p_title:'吃的吃的',
        p_summary:'123',
        p_priceA:'5000',
        p_duration:'30'
      },{
        p_icon:'test1.jpg',
        p_title:'吃的吃的',
        p_summary:'123',
        p_priceA:'5000',
        p_duration:'30'
      }
    ]
  };
  res.send(response);
})


router.get('/api/product/one',function(req,res,next){
  var response = {
    status:1,
    product:{
        p_icon:'test1.jpg',
        p_title:'三分钟服务',
        p_summary:'123',
        p_priceA:'5000',
        p_duration:'30',
        p_fit_people:'123123123123123131231231231',
        p_introduce:'三月，醉一场青春的流年。慢步在三月的春光里，走走停停，看花开嫣然，看春雨绵绵，感受春风拂面，春天，就是青春的流年。青春，是人生中最美的风景。青春，是一场花开的遇见；青春，是一场痛并快乐着的旅行；青春，是一场轰轰烈烈的比赛；青春，是一场鲜衣奴马的争荣岁月；青春，是一场风花雪月的光阴青春往事，多么甜蜜；青春岁月，多么靓丽；青春流年，如火如荼。青春里，我们向着梦想前进。跌倒过，伤心过，快乐过，痛苦过，孤独过，彷徨过，迷茫过。总是，在悠悠的岁月中徘徊；总是，在如春的生命中成长；总是，在季节的交替中感悟人生四季的美妙与韵律；总是，在多愁善感中体悟青春的美好与无奈。'
      }
  };
  res.send(response);
})
router.post('/api/pv/one',function(req,res,next){
  //获取post请求的数据
  // console.log(req.body)
  let {pid}=req.body
  var response = {
    status:1,
  };
  res.send(response);
})
router.get('/api/book/all',function(req,res,next){
  //获取post请求的数据
  // console.log(req.body)
  let {pid}=req.body
  var response = {
    status:1,
    books:[{
      b_id:1,
      b_price:200,
      p_icon:'test2.jpg',
      p_title:'中兴祥林',
      b_time:'2018.09.09',
      b_state:1
    }]
  };
  res.send(response);
})

module.exports = router;
